package com.lnj.messages.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lnj.bean.model.Coupon;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface CouponMapper extends BaseMapper<Coupon> {
    /**
     * 减少优惠券库存
     * @param couponId 优惠券ID
     * @return 影响行数
     */
    @Update("update coupon set totalCount = totalCount - 1 where id = #{couponId} and totalCount > 0")
    int reduceStock(Long couponId);
}
